<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2022/5/16
 * Time: 16:21
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

namespace app\printer\controller;

use app\BaseController;
use app\common\model\PrinterOrder;
use think\facade\Log;

class Printer extends BaseController
{
    //拒绝
    public function refuse()
    {
        $param = file_get_contents('php://input');
        Log::info(json_encode($param));
        return json([
            "data" => "OK"
        ]);
    }

    /**
     * 完成
     * @return \think\response\Json
     * @throws \think\Exception
     */
    public function complete()
    {
        $param = $this->request->param();
        Log::info("*********************************** 打印完成 ***********************************");
        Log::info($param);
        $result = (new PrinterOrder())->getPrinterByOrderId($param);
        if($result) {
            return json([
                "data" => "OK"
            ]);
        }else{
            return json([
                "data" => "Fail"
            ]);
        }
    }

    /**
     * 状态
     * @return \think\response\Json
     */
    public function state()
    {
        $param = $this->request->param();
        Log::info("*********************************** 设备状态 ***********************************");
        Log::info($param);
        return json([
            "data" => "OK"
        ]);
    }

    /**
     * 按键
     * @return \think\response\Json
     */
    public function keywords()
    {
        $param = file_get_contents('php://input');
        Log::info(json_encode($param));
        return json([
            "data" => "OK"
        ]);
    }

}